package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级相关接口")
public class NursingLevelController extends BaseController{
    @Autowired
    private NursingLevelService nursingLevelService;
    @GetMapping("/listByPage")
    @ApiOperation("分页查询护理等级")
    public PageResponse<NursingLevelVo> find(@ApiParam("每页展示数量") Integer pageSize, @ApiParam("当前页码") Integer pageNum,
                                             @ApiParam("护理等级名称") String name, @ApiParam("护理等级状态") Integer status){
        return nursingLevelService.find(pageSize,pageNum,name,status);
    }
    @PostMapping("insert")
    @ApiOperation("新增护理等级")
    public ResponseResult add(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.add(nursingLevelDto);
        return success();
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult findById(@PathVariable Long id){
        NursingLevelVo nursingLevelVo=nursingLevelService.findById(id);
        return success(nursingLevelVo);
    }
    @PutMapping("update")
    @ApiOperation("根据id更新护理等级")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return success();
    }
    @DeleteMapping("delete/{id}")
    @ApiOperation("根据id删除护理等级")
    public ResponseResult deleteById(@PathVariable Long id){
        nursingLevelService.deleteById(id);
        return success();
    }
    @PutMapping("{id}/status/{status}")
    @ApiOperation("根据id修改护理计划状态")
    public ResponseResult updateStatusById(@PathVariable Long id,@PathVariable Integer status){
        nursingLevelService.updateStatusById(id,status);
        return success();
    }
}
